package com.eshore.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import com.eshore.khala.core.basestarter.autoconfigure.MybatisPlusAutoConfiguration;
import com.eshore.khala.core.basestarter.autoconfigure.MybatisPlusProperties;
import org.springframework.context.annotation.Bean;
import com.eshore.khala.core.extension.plugins.OptimisticLockerInterceptor;
import com.eshore.khala.core.extension.plugins.PaginationInterceptor;

/**
 */
@SuppressWarnings("deprecation")
@Configuration
@EnableConfigurationProperties(MybatisPlusProperties.class)
@AutoConfigureAfter(MybatisPlusAutoConfiguration.class)
@MapperScan("com.eshore.demo.*.mapper")
public class MybatisPlusConfig {

    @Value("${mybatis-plus.mapper-locations:/mapper/*/*Mapper.xml}")
    private String mapperLocation;
    /**
     * 1.分页插件
     * 2.多租户
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor(){
        return new OptimisticLockerInterceptor();
    }
}
